package com.lanlian.cayman.adapter;

import android.content.Context;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lanlian.cayman.R;
import com.lanlian.cayman.utils.MResUtil;
import com.lanlian.commonlib.bean.RankInfo;

import java.util.List;

/**
 * <pre>
 *     author : huxiaobo
 *     e-mail : huxiaobo@xlanlian.com
 *     date   : 2018/8/15 16:55
 *     desc   : todo
 *     version: 1.0
 * </pre>
 */
public class TradeChartsAdapter extends BaseQuickAdapter<RankInfo, BaseViewHolder> {

    private Context mContext;
    private List<RankInfo> mList;

    public TradeChartsAdapter(Context context, int layoutResId, @Nullable List<RankInfo> data) {
        super(layoutResId, data);
        this.mContext = context;
        this.mList = data;
    }

    @Override
    protected void convert(BaseViewHolder helper, RankInfo item) {
        helper.setBackgroundColor(R.id.lay_position, (helper.getLayoutPosition() + 1) % 2 == 0 ?
                mContext.getResources().getColor(R.color.color_bg_text_view_style2) :
                mContext.getResources().getColor(R.color.color_bg_text_view_style3));
        helper.setText(R.id.tv_rank_no, String.valueOf(helper.getAdapterPosition() + 1));
        helper.setText(R.id.tv_no, item.getNo() == null ? "---" : item.getNo().toString());
        helper.setText(R.id.tv_name, item.getFollowRealName());
        if (item.getProfitMoney().doubleValue() > 0) {
            helper.setText(R.id.tv_money, "+" + item.getProfitMoney().toString());
            helper.setTextColor(R.id.tv_money, MResUtil.getUpColor());
        } else if (item.getProfitMoney().doubleValue() < 0) {
            helper.setText(R.id.tv_money, item.getProfitMoney().toString());
            helper.setTextColor(R.id.tv_money, MResUtil.getDownColor());
        } else {
            helper.setText(R.id.tv_money, item.getProfitMoney().toString());
            helper.setTextColor(R.id.tv_money, mContext.getResources().getColor(R.color.color_text_style1));
        }
    }

}
